home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group00b.txt / 000126_icon-group-sender_Mon Oct 30 13:11:36 2000.msg < prev    next >
Internet Message Format  |  2001-01-03  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9UKBR606127
  4.     for icon-group-addresses; Mon, 30 Oct 2000 13:11:27 -0700 (MST)
  5. Message-Id: <200010302011.e9UKBR606127@baskerville.CS.Arizona.EDU>
  6. Date: Mon, 30 Oct 2000 09:24:12 -0700
  7. From: Steve Wampler <swampler@noao.edu>
  8. X-Accept-Language: en
  9. To: Atle <trollet@skynet.be>
  10. CC: icon-group@cs.arizona.edu
  11. Subject: Re: Yet another Newbie question....
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14. Content-Length: 2278
  15.  
  16. Atle wrote:
  17. > symbiot@my-deja.com wrote:
  18. > > Hi,
  19. > >
  20. > > And thanks in advance to all who have been helping me thru this
  21. > > learning curve of getting started in ICON.
  22. > >
  23. > > My present problem is trying to write a rountine that counts only
  24. > > letters in text and skips blanks, numbers, punctuation, etc.
  25. > >
  26. > > I tried....
  27. > >
  28. > > if member(&letters,line[index]) then totalcount +:= 1
  29. > >
  30. > > ...but for some unexplicable reason, it barfed on the very first
  31. > > character with
  32. > >
  33. > > set or table expected.
  34. > > Offending value &letters
  35. > >
  36. > > Isn't &letters a cset? You can use it in other "set" functions....can't
  37. > > you? What am I missing?
  38. > >
  39. > > Assistance appreciated!
  40.  
  41. > I have no idea if this gets you anywhere, but since there doesn't seem to be many pros out there to help either of us right now ...
  42.  
  43. Hmmm, I saw several replies, but perhaps they weren't as clear as they could be:
  44.  
  45. member(s, e) requires that s be either an Icon set or an Icon table.  A cset is
  46. neither, hence the error (maybe member should also accept a cset as a first
  47. argument, as it does in Unicon, but it doesn't).
  48.  
  49. A simple way to see if a character is contained in a cset is to use set
  50. intersection
  51. and see if the intersection contains anything, as in:
  52.  
  53.    if *(cset1 ** "a") > 0 then write("a is in ",cset1)
  54.                           else write("a is not in ",cset1)
  55.  
  56. Note that this can be used to efficiently check to see an any of several
  57. characters
  58. are in the cset *simultaneously*, as in:
  59.  
  60.    if *(cset1 ** string1) > 0 then write(string1," has characters found in
  61. ",cset1)
  62.                               else write(string1," has no characters from
  63. ",cset1)
  64.  
  65. In general, the set operations ++, **, and -- can be used very effectively with
  66. csets.  As a final example, consider the problem of finding all the characters
  67. in string string1 that do *not* appear in cset cset1:
  68.  
  69.    write("The characters in ",string1," not found in ",cset1," are
  70. '",string1--cset1,"'")
  71.  
  72. Does this help?  The original problem isn't related to the differences between
  73. strings
  74. and csets (since Icon will coerce one to the other as needed), but with assuming
  75. that
  76. an Icon cset can be used anywhere an Icon set can be used.
  77.  
  78. --
  79. Steve Wampler-  SOLIS Project, National Solar Observatory
  80. swampler@noao.edu
  81.